From 47af731db716f2e2789610ad716845b8d53275cb Mon Sep 17 00:00:00 2001 From: tsteven4 Date: Sun, 24 Feb 2013 18:13:28 +0000 Subject: [PATCH] Fix a couple of issues with the new gpx writer having to do with chains and garmin special data. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4324 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/garmin_fs.cc | 12 ++++++++++++ gpsbabel/gpx.cc | 16 ++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/gpsbabel/garmin_fs.cc b/gpsbabel/garmin_fs.cc index f75afe53d..fff3631c1 100644 --- a/gpsbabel/garmin_fs.cc +++ b/gpsbabel/garmin_fs.cc @@ -234,13 +234,25 @@ garmin_fs_xml_fprint(gbfile* ofd, const waypoint* waypt, "http://www.garmin.com/xmlschemas/GpxExtensions/v3/GpxExtensionsv3.xsd"); #endif if WAYPT_HAS(waypt, proximity) { +#if OLDGPX gbfprintf(ofd, "%*s%.6f\n", space * 2, "", waypt->proximity); +#else + writer.writeTextElement("gpxx:Proximity", QString::number(waypt->proximity, 'f', 6)); +#endif } if WAYPT_HAS(waypt, temperature) { +#if OLDGPX gbfprintf(ofd, "%*s%.6f\n", space * 2, "", waypt->temperature); +#else + writer.writeTextElement("gpxx:Temperature", QString::number(waypt->temperature, 'f', 6)); +#endif } if WAYPT_HAS(waypt, depth) { +#if OLDGPX gbfprintf(ofd, "%*s%.6f\n", space * 2, "", waypt->depth); +#else + writer.writeTextElement("gpxx:Depth", QString::number(waypt->depth, 'f', 6)); +#endif } if (gmsd->flags.display) { const char* cx; diff --git a/gpsbabel/gpx.cc b/gpsbabel/gpx.cc index 880a1ffe8..bb408f4ac 100644 --- a/gpsbabel/gpx.cc +++ b/gpsbabel/gpx.cc @@ -1582,6 +1582,7 @@ fprint_xml_chain(xml_tag* tag, const waypoint* wpt) #endif } if (tag->parentcdata) { +#if OLDGPX // retain whitespacing, but nuke leading NL as the above will add a trailing. char* otmp_ent, *tmp_ent = NULL; @@ -1592,6 +1593,13 @@ fprint_xml_chain(xml_tag* tag, const waypoint* wpt) tmp_ent = otmp_ent; gbfprintf(ofd, "%s", tmp_ent); xfree(otmp_ent); +#else + // FIXME: The length check is necessary to get line endings correct in our test suite. + // Writing the zero length string eats a newline, at least with Qt 4.6.2. + if (tag->parentcdatalen > 0) { + writer.writeCharacters(tag->parentcdata); + } +#endif } tag = tag->sibling; } @@ -1811,18 +1819,18 @@ gpx_write_common_extensions(const waypoint* waypointp, const char* indent) writer.writeStartElement("extensions"); if (waypointp->depth != 0) { if (opt_humminbirdext) { - writer.writeTextElement("h:depth", QString::number(waypointp->depth * 100.0)); + writer.writeTextElement("h:depth", QString::number(waypointp->depth * 100.0, 'f', 6)); } if (opt_garminext) { - writer.writeTextElement("gpxx:Depth", QString::number(waypointp->depth)); + writer.writeTextElement("gpxx:Depth", QString::number(waypointp->depth, 'f', 6)); } } if (waypointp->temperature != 0) { if (opt_humminbirdext) { - writer.writeTextElement("h:temperature", QString::number(waypointp->temperature)); + writer.writeTextElement("h:temperature", QString::number(waypointp->temperature, 'f', 6)); } if (opt_garminext) { - writer.writeTextElement("gpxx:Temperature", QString::number(waypointp->temperature)); + writer.writeTextElement("gpxx:Temperature", QString::number(waypointp->temperature, 'f', 6)); } } if (opt_garminext && (waypointp->heartrate != 0 || waypointp->cadence != 0)) { -- 2.30.2